import os
from threading import Thread
import subprocess
def ping(ip):
    cmd = "ping %s -n 1" % ip
    ret = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    if 0 == ret.returncode:
        print(ip)
        
for i in range(255):
    t = Thread(target=ping, args=("192.168.%s.1" % i, ))
    t.start()